package com.flin.icesilkworm.examination.bas.populator;
import java.util.Map;

import com.flin.icesilkworm.examination.bas.constant.ITheExaminationPaperRelConstant;
import com.flin.icesilkworm.examination.bas.exp.TheQuestionItemExample;
import com.flin.icesilkworm.examination.gen.bas.populator.GeneratedTheQuestionItemPopulator;
import com.flin.icesilkworm.framework.jdbc.interceptors.JdbcExampleSupport;
import com.flin.icesilkworm.framework.jdbc.objects.StringAttribute;
import com.flin.icesilkworm.framework.ui.pojo.standard.StandardUIItemForm;

public class TheQuestionItemPopulator extends GeneratedTheQuestionItemPopulator  {


	private static TheQuestionItemPopulator instance = new TheQuestionItemPopulator();
	

	public static TheQuestionItemPopulator newInstance() {
		return instance;
	}
	
	//针对每一个查询条件组装方法
	protected void loadExampleByKey(JdbcExampleSupport<?> example, String key,
			StringAttribute fieldAttr, StandardUIItemForm item) {
		
		TheQuestionItemExample exp = (TheQuestionItemExample)example;
		
		//
		
	}
	
	
	//条件组装后，需要进行默认判断是否需要扩展
	protected boolean defaultDealExample(TheQuestionItemExample example,Map<String,String> additions) {
		
//		PopulatorSupport.setDefaultAuthCondition(example);
		
		boolean t =  super.defaultDealExample(example,additions);//true,直接结束，不做后续的自动条件增加，false:不做直接终止
	

		
//		JdbcExampleSupport s = example.getJoinExample("tqi_.");
//		if(s != null){
//			s.link( "tqi_.TITLE_ID = 1");
//		}
//		if(  additions.containsKey(JOIN_TheExaminationPaperRel))  
//			
//			example.joinTheExaminationPaperRelFkItemId().link( "tqi_.TITLE_ID = 1" );
		
		return t;
	}
	
	protected  Map<String,Map<String,StringAttribute>> getStringAttributes(){
		
		
		Map<String,Map<String,StringAttribute>> map = super.getStringAttributes();
		map.put("tqi", ITheExaminationPaperRelConstant.STRING_ATTRIBUTES);
		return map;
//		CollectionUtils.toMap(
//			"this",ITheQuestionItemConstant.STRING_ATTRIBUTES
//				
//			,"quesBankId",ITheQuestionBankConstant.STRING_ATTRIBUTES 
//				
//			,"subId",ITheBasicSubjectsConstant.STRING_ATTRIBUTES 
//				
//			,"parentId",ITheQuestionItemConstant.STRING_ATTRIBUTES 
//				
//			,"teacherId",ITheBasicTeacherConstant.STRING_ATTRIBUTES 
//				
//			,"qap",ITheExaminationPaperConstant.STRING_ATTRIBUTES
//			
//		);
	}
	
	//遇到别名时组装方式
	public JdbcExampleSupport<?> joinExample(String key, JdbcExampleSupport<?> example,String op,Map<String,String> params) {
		
		return super.joinExample(key,example,op,params);
	}
	
	//针对每个查询条件的自定义条件
	public boolean beforeLoadExample(JdbcExampleSupport<?> example,String key, StringAttribute fieldAttr,
			String op, StandardUIItemForm item,Map<String,String> params) {
		
		return false;
	}
																																																																																																
}